package com.course.controller;

import com.course.component.http.Crp;
import com.course.component.http.requ.RequestArticle;
import com.course.component.http.requ.RequestCategory;
import com.course.masterservice.ArticlesMasterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Copyright: Copyright (c)  林中小鸟  All rights reserved.
 * @author: moon
 * @date: 2022/9/17 14:26
 * @Description: **********************
 */
@RestController
@RequestMapping(value = "/x/article")
public class ArticleController {

    @Autowired
    private ArticlesMasterService articlesMasterService;

    @GetMapping(value = "list")
    public Crp list(RequestArticle requestArticle){
        return Crp.success(articlesMasterService.getPageList(requestArticle));
    }

    @GetMapping(value = "detail/{id}")
    public Crp detail(@PathVariable Long id){
        return Crp.success(articlesMasterService.getArticle(id));
    }

    @DeleteMapping(value = "del")
    public Crp del(@RequestBody RequestArticle requestArticle){
        return Crp.success(articlesMasterService.del(requestArticle));
    }

    @PostMapping(value = "edit")
    public Crp update(@RequestBody  RequestArticle requestArticle){
        return Crp.success(articlesMasterService.update(requestArticle));
    }
}
